from django.contrib.auth.decorators import login_required, user_passes_test
from django.shortcuts import render

from utils.context import get_context


@login_required
def index(request):
    return render(request, 'cms/index.html')


@login_required
def publish(request):
    context = get_context()
    return render(request, 'cms/publish.html', context=context)


@login_required
def posts(request):
    context = get_context()
    return render(request, 'cms/posts.html', context=context)


@login_required
def topics(request):
    return render(request, 'cms/topics.html')


@login_required
def topics_add(request):
    return render(request, 'cms/add-topic.html')


@login_required
@user_passes_test(lambda u: u.is_superuser)
def types(request):
    return render(request, 'cms/types.html')


@login_required
@user_passes_test(lambda u: u.is_superuser)
def types_add(request):
    return render(request, 'cms/add-type.html')
